﻿using C1.WPF.FlexGrid;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace SteelDetection
{
    /// <summary>
    /// WindowSysConfig.xaml 的交互逻辑
    /// </summary>
    public partial class WindowHistoryAlert : Window
    {
        public WindowHistoryAlert()
        {
            InitializeComponent();
            //c1FlexGrid.CellFactory = new ConditionalCellFactory("confirmed");
        }


        private void CloseButton_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }
    }

    public class ConditionalCellFactory : CellFactory
    {
        string colname;
        public ConditionalCellFactory(string colname)
        {
            this.colname = colname;
        }

        public override void CreateCellContent(C1FlexGrid grid, Border bdr, CellRange rng)
        {
            
            //format cells in second column  
            var istrue=grid[rng.Row, grid.Columns[colname].Index] as bool?;
            if (istrue==true)
            {
                bdr.Background = new SolidColorBrush(Colors.LightSeaGreen);
            }
            else 
            {
                bdr.Background = new SolidColorBrush(Colors.IndianRed);

            }
            base.CreateCellContent(grid, bdr, rng);
        }
    }
}
